package com.coderman.topn.bitset;

import java.util.ArrayList;
import java.util.BitSet;
import java.util.List;
import java.util.Random;

/**
 * @Author fanchunshuai
 * @Date 2019/11/25 10
 * @Description:
 *
 * https://www.cnblogs.com/xujian2014/p/5491286.html
 */
public class BitSetDemo {
    public static void main(String[] args) {
        Random random = new Random();
        List<Integer> result = new ArrayList<>();

        for(int i = 0;i < 100;i++){
           int num = random.nextInt(64);
            result.add(num);
        }


        System.out.println("产生的随机数有");
        for(int i=0;i<result.size();i++)
        {
            System.out.println(result.get(i));
        }

        BitSet bitSet = new BitSet(64);
        for (int i =0;i < result.size();i++){
            bitSet.set(result.get(i));
        }

        for (int i =0;i < result.size();i++){
            if(!bitSet.get(i)){
                System.out.println(result.get(i)+" not exit.");
            }
        }
    }
}
